<html>
<head><meta charset="utf-8"><title>Updating LLVM... · t-compiler/wg-llvm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/index.html">t-compiler/wg-llvm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Updating.20LLVM.2E.2E.2E.html">Updating LLVM...</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="169782825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Updating%20LLVM.../near/169782825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Updating.20LLVM.2E.2E.2E.html#169782825">(Jul 06 2019 at 21:16)</a>:</h4>
<p>I'm trying to update our LLVM version to current master. Ran into this linker error:</p>
<div class="codehilite"><pre><span></span>/usr/bin/ld: /home/nikic/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-5c2422e2d705ee7d.rlib(std-5c2422e2d705ee7d.std.e5hw7qqp-cgu.2.rcgu.o): TLS transition from R_X86_64_TLSLD to R_X86_64_TPOFF32 against `_ZN3std10sys_common11thread_info11THREAD_INFO7__getit5__KEY17hc720e1025694e38eE&#39; at 0x15 in section `.text._ZN3std10sys_common11thread_info3set17hbe84d5bac17e4e00E&#39; failed
</pre></div>


<p>I'm a bit stumped on how I would go about debugging something like this.</p>



<a name="169808467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Updating%20LLVM.../near/169808467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Updating.20LLVM.2E.2E.2E.html#169808467">(Jul 07 2019 at 11:45)</a>:</h4>
<p>I suspect this is due to <a href="https://reviews.llvm.org/D62106" target="_blank" title="https://reviews.llvm.org/D62106">https://reviews.llvm.org/D62106</a>. It looks like __tls_get_addr now uses a GOTPCREL rather than PLT32 relocation and that somehow breaks things.</p>



<a name="169808468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Updating%20LLVM.../near/169808468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Updating.20LLVM.2E.2E.2E.html#169808468">(Jul 07 2019 at 11:45)</a>:</h4>
<p>Try another linker, possibly a linker bug with your particular version of binutil.</p>



<a name="169808764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Updating%20LLVM.../near/169808764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Updating.20LLVM.2E.2E.2E.html#169808764">(Jul 07 2019 at 11:55)</a>:</h4>
<p>At least if I understand the error correctly, then "ELF handling for Thread-Local storage document” specifies a mechanism to transition from TLSLD to TPOFF32</p>



<a name="169808820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Updating%20LLVM.../near/169808820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Updating.20LLVM.2E.2E.2E.html#169808820">(Jul 07 2019 at 11:56)</a>:</h4>
<p>As far as debugging goes, I would also attempt to 1) minimize and 2) look at the assembly to understand what relocations llvm generates</p>



<a name="169808983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Updating%20LLVM.../near/169808983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Updating.20LLVM.2E.2E.2E.html#169808983">(Jul 07 2019 at 12:02)</a>:</h4>
<p>Yeah, I've minimized this (just a thread local linked in from a different crate is enough) and looked at the objdump differences, which turned out to just be GOT vs PLT for the __tls_get_addr symbol.</p>



<a name="169809000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Updating%20LLVM.../near/169809000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Updating.20LLVM.2E.2E.2E.html#169809000">(Jul 07 2019 at 12:02)</a>:</h4>
<p>Tried a different linker -- works with gold.</p>



<a name="169809374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Updating%20LLVM.../near/169809374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Updating.20LLVM.2E.2E.2E.html#169809374">(Jul 07 2019 at 12:12)</a>:</h4>
<p>Wait no, it seems to work with both binutils ld and gold when explicitly specified via <code>-C linker</code>. But fails without. What is our default linker?</p>



<a name="169809657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Updating%20LLVM.../near/169809657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Updating.20LLVM.2E.2E.2E.html#169809657">(Jul 07 2019 at 12:20)</a>:</h4>
<p>Looks like the default linker is <code>cc</code>.</p>



<a name="169811646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Updating%20LLVM.../near/169811646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Updating.20LLVM.2E.2E.2E.html#169811646">(Jul 07 2019 at 13:13)</a>:</h4>
<p>Okay, it doesn't work with -Clinker after all. Turns out I just get an empty executable in that case because crt0 is not linked in. After dropping libc it also happens with an explicit <code>-C linker=/usr/bin/ld</code>.</p>



<a name="169820674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Updating%20LLVM.../near/169820674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Updating.20LLVM.2E.2E.2E.html#169820674">(Jul 07 2019 at 18:10)</a>:</h4>
<p>There’s <code>linker-flavour</code> option which specifies what kind of a linker you’re using.</p>



<a name="169820686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Updating%20LLVM.../near/169820686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Updating.20LLVM.2E.2E.2E.html#169820686">(Jul 07 2019 at 18:11)</a>:</h4>
<p>My go-to alternative is usually <code>clang -fuse-ld=lld</code></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>